﻿using MediatR;
using SystemMHB.API.Application.Command.ProcessTaskCommand;
using SystemMHB.Infrstructer.Interface;

namespace SystemMHB.API.Application.CommandHandlers.ProcessTaskCommandHandler
{
    public class ProcessTaskUpdateCommandHandler:IRequestHandler<ProcessTaskUpdateCommand,int>
    {
        /// <summary>
        /// 工序任务仓储接口
        /// </summary>
        IProcessTaskRepository _process;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_process">工序任务仓储接口</param>
        public ProcessTaskUpdateCommandHandler(IProcessTaskRepository _process)
        {
            this._process = _process;
        }

        public async Task<int> Handle(ProcessTaskUpdateCommand request, CancellationToken cancellationToken)
        {
            var qoutr = await _process.GetModelAsync(request.processTaskId);
            qoutr.taskStatus = request.taskStatus;
            qoutr.UpdateTime=DateTime.Now.ToUniversalTime();
            qoutr.UpdateName ="李四";
            return await _process.UpdateAsync(qoutr);
        }
    }
}
